package role

import (
	"context"
	"jinrigaoping/rpc/sys/sys"

	"jinrigaoping/api/superadmin/internal/svc"
	"jinrigaoping/api/superadmin/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type RoleAddLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewRoleAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RoleAddLogic {
	return &RoleAddLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *RoleAddLogic) RoleAdd(req *types.SysRoleAddReq) (resp *types.SysRoleAddRes, err error) {

	_, err = l.svcCtx.SysRpc.SysRoleAdd(l.ctx, &sys.SysRoleAddReq{
		RoleName:   req.RoleName,
		Remark:     req.Remark,
		MenuIdList: req.MenuIdList,
	})
	if err != nil {
		return nil, err
	}

	return &types.SysRoleAddRes{}, nil
}
